package com.arpa.wms.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: rfwang
 * @Date 2021/04/12
 * @Description:
 */
public enum OrderTagEnum implements IEnum<String> {
    /**
     * 订单标识
     */
    SINGLE_ITEM("1","单品单件"),
    MANY_ITEM("2","单品多件"),
    MORE_PRODUCT("3","多品"),
    MOST_POPULAR_ITEM("4","爆品"),
    QUANTITY("5","按单"),
    ;

    /**
     * 值
     */
    private String value;

    /**
     * 描述
     */
    private String desc;

    OrderTagEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String translate(String value){
        OrderTagEnum item = ENUM_MAP.get(value);
        if(item != null){
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }

    private static final Map<String, OrderTagEnum> ENUM_MAP = new HashMap();

    static {
        for(OrderTagEnum item: values()){
            ENUM_MAP.put(item.getValue(), item);
        }
    }

    public static OrderTagEnum getEnumByValue(String value) {
        return ENUM_MAP.get(value);
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return desc;
    }

}
